package jmine.tec.utils.spring;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.InitializingBean;

/**
 * @author takeshi
 */
public class PropertyModifier implements InitializingBean {

    private Object source;

    private String property;

    private Object value;

    /**
     * @return the source
     */
    public Object getSource() {
        return source;
    }

    /**
     * @return the property
     */
    public String getProperty() {
        return property;
    }

    /**
     * @return the value
     */
    public Object getValue() {
        return value;
    }

    /**
    * {@inheritDoc}
     */
    public void afterPropertiesSet() throws Exception {
        if(this.source == null) {
            throw new NullPointerException("source cannot be null");
        }
        if(this.property == null) {
            throw new NullPointerException("property cannot be null");
        }
        BeanUtils.setProperty(source, property, value);
    }

    /**
     * @param source the source to set
     */
    public void setSource(Object source) {
        this.source = source;
    }

    /**
     * @param property the property to set
     */
    public void setProperty(String property) {
        this.property = property;
    }

    /**
     * @param value the value to set
     */
    public void setValue(Object value) {
        this.value = value;
    }

}
